---
title: 护理不良事件
---
<template>
  <my-wrapper :header="null">
  <div>
    <el-button plain type="primary" @click="rowNew">新增</el-button>
    <el-button plain type="success" >导出</el-button>
    <el-button plain type="success" >审核</el-button>
    <el-button plain type="danger" >审核不通过</el-button>
    <el-button plain type="warning" >取消审核</el-button>
    <el-button plain type="primary" >转发</el-button>
    <el-button plain type="success" >处理</el-button>
    <!--表格内容-->
    <el-table
      ref="list"
      :data="tableData"
      style="width: 100%;margin-top: 1vw"
      border
      stripe
      highlight-current-row
      :default-sort="{prop: 'date', order: 'descending'}"
      @row-click="handleRowClick"
      @select-all="handleCheckedAllAndCheckedNone"
      @select="handleCheckedAllAndCheckedNone">
      <el-table-column property="col3" label="姓名" width="150" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col1" label="科室" width="150" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col2" label="床号" width="120" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col4" label="性别" width="120" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col5" label="年龄" width="120" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col6" label="住院号" width="120" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col7" label="入院日期" width="150" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="col8" label="发生日期" width="150" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column property="status" label="提交状态" width="120" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span v-if="scope.row.status=='1'" style="margin-left: 5px;color: #007df8">已保存</span>
          <span v-if="scope.row.status=='2'" style="margin-left: 5px;color: #13ce66">已审核</span>
          <span v-if="scope.row.status=='-99'" style="margin-left: 5px;color: red">审核不通过</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button plain circle icon="el-icon-edit-outline" type="primary" title="编辑" size="small"
            @click="rowEdit(scope.$index, scope.row)"></el-button>
          <el-button plain circle icon="el-icon-check" type="success" title="审核通过" size="small"
                     @click="rowDel(scope.$index, scope.row, $event);"></el-button>
          <el-button plain circle icon="el-icon-close" type="danger" title="审核不通过" size="small"
                     @click="rowDel1(scope.$index, scope.row, $event);"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination
      :page-sizes="[10, 20, 30, 40]"
      :page-size="10"
      :total="100"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!--编辑-弹出层-->
    <my-dialog
      title="新增"
      :visible.sync="isShowEditDialog"
      draggable
      target="body"
      width="1000px"
      height="700px"
      @submit="handleSubmit"
      @close="dialogClose">
      <el-form
        ref="editForm"
        :model="formFileds"
        label-width="55px"
        :rules="rules">
        <el-row>
            <el-col :span="12">
              <el-form-item label="科室" label-width="100px">
                <el-input v-model="formFileds.col1"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="床号" label-width="120px">
                <el-input v-model="formFileds.col2"></el-input>
              </el-form-item>
            </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="5">
            <el-form-item label="姓名" prop="name" label-width="100px">
              <el-input v-model="formFileds.col3"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="性别">
              <el-input v-model="formFileds.col4"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="年龄" prop="name">
              <el-input v-model="formFileds.col5"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="住院号" prop="name">
              <el-input v-model="formFileds.col6"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="入院时间" prop="name">
              <el-date-picker v-model="formFileds.col7" value-format="yyyy-MM-dd" :editable="false" :clearable="false"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="发生时间" prop="address" label-width="100px">
            <el-date-picker v-model="formFileds.col8" value-format="yyyy-MM-dd" :editable="false" :clearable="false"></el-date-picker>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="不良时间发生的经过及后果" prop="address" label-width="100px">
            <el-input type="textarea" v-model="formFileds.col9"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="不良事件发生类型" prop="address" label-width="120px">
            <el-checkbox-group v-model="checkList1">
              <el-checkbox label="1">查对错误</el-checkbox>
              <el-checkbox label="2">治疗错误</el-checkbox>
              <el-checkbox label="3">用药错误</el-checkbox>
              <el-checkbox label="4">输血错误</el-checkbox>
              <el-checkbox label="5">医嘱处理错误</el-checkbox>
              <el-checkbox label="6">液体渗漏</el-checkbox>
              <el-checkbox label="7">标本差错</el-checkbox>
              <el-checkbox label="8">实习生单独操作错误</el-checkbox>
              <el-checkbox label="9">文书书写错误</el-checkbox>
              <el-checkbox label="10">院内压疮</el-checkbox>
              <el-checkbox label="11">坠床</el-checkbox>
              <el-checkbox label="12">跌倒</el-checkbox>
              <el-checkbox label="13">走失</el-checkbox>
              <el-checkbox label="14">导管脱落/拔出</el-checkbox>
              <el-checkbox label="15">咽入异物</el-checkbox>
              <el-checkbox label="16">针刺伤</el-checkbox>
              <el-checkbox label="17">外伤/烫伤</el-checkbox>
              <el-checkbox label="18">烧伤</el-checkbox>
              <el-checkbox label="19">火灾</el-checkbox>
              <el-checkbox label="20">失窃</el-checkbox>
              <el-checkbox label="21">其他</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="不良事件定性" prop="address" label-width="120px">
            <el-checkbox-group v-model="checkList2">
              <el-checkbox label="1">护理缺陷</el-checkbox>
              <el-checkbox label="2">护理差错</el-checkbox>
              <el-checkbox label="3">护理事故</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="本科室处理意见及改进措施" prop="address" label-width="120px">
            <el-input type="textarea" v-model="formFileds.col9"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="护士长签名" label-width="120px">
              <el-input v-model="formFileds.col10"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="时间" label-width="120px">
              <el-date-picker v-model="formFileds.col11" value-format="yyyy-MM-dd" :editable="false" :clearable="false"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="护理部意见" prop="address" label-width="120px">
            <el-input type="textarea" v-model="formFileds.col12"></el-input>
          </el-form-item>
        </el-row>
<!--        <el-form-item>-->
<!--          <el-button type="primary" @click="handleSubmit(formFileds.id)" class="pull-right margin-l-25">确定</el-button>-->
<!--          <el-button @click="isShowEditDialog = false;" class="pull-right">取消</el-button>-->
<!--        </el-form-item>-->
      </el-form>
    </my-dialog>
  </div>
  </my-wrapper>
</template>

<script>
  export default {
    name: "Table",
    data() {
      return {
        checkList:[],
        checkList1:[],
        checkList2:[],
        checkList3:[],
        checkList4:[],
        checkList5:[],
        checkList6:[],
        checkList7:[],
        checkList8:[],
        formFileds: {
          date: '',
          name: '',
          address: '',
          id: '',
          col1:undefined,
          col2:undefined,
          col3:undefined,
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          col10:undefined,
          col11:undefined,
          col12:undefined,
          col13:undefined,
          col14:undefined,
          col15:undefined,
          col16:undefined,
          col17:[],//checkList
          col18:[],//checkList1
          col19:[],//checkList2
          col20:[],//checkList3
          col21:[],//checkList4
          col22:[],//checkList5
          col23:[],//checkList6
          col24:[],//checkList7
          col25:undefined,
          col26:undefined,
          col27:undefined,
          col28:undefined,
          col29:undefined,
          col30:undefined,
          col31:undefined,
          col32:undefined,
          col33:undefined,
          col34:undefined,
          col35:undefined,
          col36:undefined,
          col37:undefined,
        },
        rules: {
          // name: [
          //   {required: true, message: '姓名不能为空', trigger: 'blur, change'}
          // ],
          // address: [
          //   {required: true, message: '地址不能为空', trigger: 'blur, change'}
          // ]
        },
        tableData: [{
          id: 1,
          date: '2016-05-02',
          col3: '王小虎',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 2,
          date: '2016-05-02',
          col3: '王小虎',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 3,
          date: '2016-05-02',
          col3: '王小虎',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 4,
          date: '2016-05-02',
          col3: '王小虎',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 5,
          date: '2016-05-02',
          col3: '患者5',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 6,
          date: '2016-05-02',
          col3: '患者6',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }, {
          id: 7,
          date: '2016-05-02',
          col3: '患者7',
          address: '男',
          col1: '内科',
          col2: '2',
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          status:'1'
        }],
        isShowEditDialog: false
      }
    },
    methods: {
      handleRowClick(row, event, column) {

        // 仅选中当前行
        this.setCurRowChecked(row);
      },
      handleCheckedAllAndCheckedNone(selection) {

        // 当前选中仅一行时操作-（当前表格行高亮）
        1 != selection.length && this.$refs.list.setCurrentRow();
      },
      dialogClose() {

        // 清空编辑表单
        this.$refs.editForm.resetFields();
      },
      //清空表单信息
      resetForm(){
        this.formFileds={
          date: '',
          name: '',
          address: '',
          id: '',
          col1:undefined,
          col2:undefined,
          col3:undefined,
          col4:undefined,
          col5:undefined,
          col6:undefined,
          col7:undefined,
          col8:undefined,
          col9:undefined,
          col10:undefined,
          col11:undefined,
          col12:undefined,
          col13:undefined,
          col14:undefined,
          col15:undefined,
          col16:undefined,
          col17:undefined,
          col18:undefined,
          col19:undefined,
          col20:undefined,
          col21:undefined,
          col22:undefined,
          col23:undefined,
          col24:undefined,
          col25:undefined,
          col26:undefined,
          col27:undefined,
          col28:undefined,
          col29:undefined,
          col30:undefined,
          col31:undefined,
          col32:undefined,
          col33:undefined,
          col34:undefined,
          col35:undefined,
          col36:undefined,
          col37:undefined,
        }
      },
      rowNew(){
        this.resetForm();
        this.isShowEditDialog = true;
      },
      rowEdit(index, row) {

        console.info(row)
        this.checkList = row.col17 == null? [] : row.col17
        this.checkList1 = row.col18 == null? [] : row.col18
        this.checkList2 = row.col19 == null? [] : row.col19
        this.checkList3 = row.col20 == null? [] : row.col20
        this.checkList4 = row.col21 == null? [] : row.col21
        this.checkList5 = row.col22 == null? [] : row.col22
        this.checkList6 = row.col23 == null? [] : row.col23
        this.checkList7 = row.col24 == null? [] : row.col24
        this.setCurRowChecked(row);
        // 给编辑弹出层赋值
        // ***这里需要注意的是：因为加了排序 所以tableData的顺序和实际显示的行顺序不一样
        for (let key in this.formFileds) {
          this.formFileds[key] = row[key];
        }
        this.isShowEditDialog = true;
      },
      handleSubmit(){
        this.formFileds.col17 = this.checkList
        this.formFileds.col18 = this.checkList1
        this.formFileds.col19 = this.checkList2
        this.formFileds.col20 = this.checkList3
        this.formFileds.col21 = this.checkList4
        this.formFileds.col22 = this.checkList5
        this.formFileds.col23 = this.checkList6
        this.formFileds.col24 = this.checkList7
        if(this.formFileds.id!=null&&this.formFileds.id!=""){
          this.handleEdit(this.formFileds.id);
        }else{
          this.formFileds.id = new Date().getTime();
          this.tableData.push(this.formFileds);
          this.resetForm();
          this.isShowEditDialog = false;
        }
      },
      handleEdit(id) {
        let that = this;
        this.$refs.editForm.validate(isValid => {
          if (!isValid) return;
          // 保存编辑后的数据
          this.tableData.forEach(function(val,index){
            if(val.id == id){
              Object.assign(that.tableData[index], that.formFileds);
            }
          })
          this.isShowEditDialog = false;
          // 考虑到可能编辑了日期-需要重新排序
          // ***注意：手动排序传参和表格的default-sort属性格式不太一样
          this.$refs.list.sort('date', 'descending');
          this.$message.success('编辑成功');
        });
      },
      rowDel(index, row, event) {
        let that = this;
        // 让当前删除按钮失焦
        event.target.blur();
        this.$confirm('确定要审核当前行吗？', '审核', {
          comfirmButtonText: '确定',
          cancelButtonText: '取消'
        }).then(() => {
          //this.tableData.splice(row.id, 1);
          this.tableData.forEach(function(val,index){
            if(val.id == row.id){
              row.status = 2;
              Object.assign(that.tableData[index], row);
            }
          })
          this.$message.success('审核成功');
          return false;
        });
      },
      rowDel1(index, row, event) {
        let that = this;
        // 让当前删除按钮失焦
        event.target.blur();
        this.$confirm('确定要审核当前行吗？', '审核不通过', {
          comfirmButtonText: '确定',
          cancelButtonText: '取消'
        }).then(() => {
          //this.tableData.splice(row.id, 1);
          this.tableData.forEach(function(val,index){
            if(val.id == row.id){
              row.status = -99;
              Object.assign(that.tableData[index], row);
            }
          })
          this.$message.success('审核成功');
          return false;
        });
      },
      // 选中当前行-当前行的复选框被勾选
      setCurRowChecked(row) {
        this.$refs.list.clearSelection();
        this.$refs.list.toggleRowSelection(row);
      }
    }
  }
</script>

<style scoped lang="scss">
.el-form {
  padding: 0 10px;
}
.el-date-editor {
  width: 100% !important;
}
::v-deep .el-table{
  font-size: 11px;
}
</style>
